#include "include/throw.h"

#define THROW_PI 3.1415

vektor g;

float DegreeToRadian(float degree) {
    double radian = degree * (THROW_PI/180);
    return radian;
}

vektor PolarToXY(float r, float alpha) {
    vektor v;
    if ((alpha > 90) || (alpha < -90)) exit(1);
    v.x = r * cos(DegreeToRadian(alpha));
    v.y = r * sin(DegreeToRadian(alpha));
    return v;
}

float GetActPositionX(objekt o, vektor g, float t) {
    float x;
    x = o.pos.x + o.v.x * t + 0.5 * g.x * pow(t, 2);
    return x;
}

float GetActPositionY(objekt o, vektor g, float t) {
    float y;
    y = o.pos.y + o.v.y * t + 0.5 * g.y * pow(t, 2);
    return y;
}

vektor GetActPosition(objekt o, vektor g, float t) {
   vektor pos;
   pos.x = GetActPositionX(o, g, t);
   pos.y = GetActPositionY(o, g, t);
   return pos;
}

vektor GetActPos(objekt o, vektor g, float t) {
    return GetActPosition(o, g, t);   
}

float GetMaximumY(objekt o, vektor g) {
    float y = o.pos.y - 0.5 * pow(o.v.y, 2) / g.y;
    return y;   
}
